--[[ Masamune - Boss2.lua ]]

--[[ Boss2 LUA script
 By Masamune ]]

function Diablo_CheckA(Unit)
	if Unit:GetHealthPct() < 75 then
		Unit:CastSpell(37669)
		Unit:SendChatMessage(14, 0, "Nightbanes, Come to my word, NOW!!!")
		Unit:SpawnCreature(500845, 290, 1461, -11.8613, 0.5, 530, 360000);
		Unit:SpawnCreature(500845, 278, 1459, -11.8613, 1.22, 530, 360000);
	end
end

function Diablo_CheckB(Unit)
	if Unit:GetHealthPct() < 50 then
		Unit:CastSpell(37669)
		Unit:SendChatMessage(14, 0, "Do you thik you can beat me???")
		Unit:SpawnCreature(500845, 290, 1461, -11.8613, 0.5, 530, 360000);
		Unit:SpawnCreature(500845, 278, 1459, -11.8613, 1.22, 530, 360000);
	end
end

function Diablo_CheckC(Unit)
	if Unit:GetHealthPct() < 25 then
		Unit:CastSpell(37669)
		Unit:SendChatMessage(14, 0, "MUAHAHAHAHA you are not that bad")
		Unit:SpawnCreature(500845, 290, 1461, -11.8613, 0.5, 530, 360000);
		Unit:SpawnCreature(500845, 278, 1459, -11.8613, 1.22, 530, 360000);
	end
end

function Diablo_CheckD(Unit)
	if Unit:GetHealthPct() < 10 then
		Unit:CastSpell(28131)
		Unit:SendChatMessage(14, 0, "Feel all my power!!!")
		Unit:SpawnCreature(500845, 290, 1461, -11.8613, 0.5, 530, 360000);
		Unit:SpawnCreature(500845, 278, 1459, -11.8613, 1.22, 530, 360000);
	end
end

function DiabloVoid_OnSpawn (Unit, Event)
	Unit:Despawn (6000, 0)
end
RegisterUnitEvent (500845, 6, "DiabloVoid_OnSpawn")

function DiabloVoid_onCombat (Unit, Event)
	Unit:CastSpell(32995)
end
RegisterUnitEvent (500845, 1, "DiabloVoid_onCombat") 

function Diablo_Chill(Unit)
	Unit:CastSpell(36148)
	Unit:SendChatMessage(14, 0, "COME BACK HERE!!!")
end

function Diablo_Shadow(Unit)
	Unit:CastSpell(33846)
	Unit:SendChatMessage(14, 0, "COME BACK HERE!!!")
end

function Diablo_OnCombat(Unit, Event)
	Unit:SendChatMessage (12, 0, "Whanna try some of my feared fists?")
	Unit:RegisterEvent("Diablo_CheckA",25000, 0)
	Unit:RegisterEvent("Diablo_CheckB",20000, 0)
	Unit:RegisterEvent("Diablo_CheckC",25000, 0)
	Unit:RegisterEvent("Diablo_CheckD",20000, 0)
	Unit:RegisterEvent("Diablo_Chill",20000, 0)
	Unit:RegisterEvent("Diablo_Shadow",31000, 0)
end

function Diablo_OnLeaveCombat(Unit)
	Unit:RemoveEvents()
end

function Diablo_KilledTarget(Unit)
	Unit:SendChatMessage(14, 0, "You are not prepared yet...")
	Unit:CastSpell(37669)
	Unit:RemoveEvents()
end

function Diablo_OnDied(Unit)
	Unit:SendChatMessage(14, 0, "Master...Why...Spartan...Grrhsljwa")
	Unit:RemoveEvents()
end

RegisterUnitEvent(500846, 1, "Diablo_OnCombat")
RegisterUnitEvent(500846, 2, "Diablo_OnLeaveCombat")
RegisterUnitEvent(500846, 3, "Diablo_OnKilledTarget")
RegisterUnitEvent(500846, 4, "Diablo_OnDied") 